﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Maticsoft.DBUtility;
using System.Data.SqlClient;

namespace ElingOA6_Admin_DSJCJ.DAL
{
    /// <summary>
    /// 信息文档呈送 数据类
    /// </summary>
    public class DocReference
    {
        public DocReference()
        {
        }
        /// <summary>
        /// 获得数据列表
        /// <creator>wangl</creator>
        /// <date>2014-03-13</date>
        /// </summary>
        public DataSet GetListByDocId(string entityNo, decimal docId)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select a.FDocId,a.FDocClsCd,a.FEntityNo,b.FDocClsName ");
            strSql.Append(" FROM t_DocReference a,t_docCls b ");
            strSql.Append(" where a.FEntityNo=@FEntityNo and a.FDocId=@FDocId AND a.FDocClsCd=b.FDocClsCd");
            SqlParameter[] parameters = {
					new SqlParameter("@FDocId", SqlDbType.Decimal),
					new SqlParameter("@FEntityNo", SqlDbType.NVarChar,50)};
            parameters[0].Value = docId;
            parameters[1].Value = entityNo;
            return DbHelperSQL.Query(strSql.ToString(),parameters);
        }

        /// <summary>
        /// 得到一个对象实体
        /// <creator>wangl</creator>
        /// <date>2014-03-13</date>
        /// </summary>
        public ElingOA6_Admin_DSJCJ.Model.DocReference DataRowToModel(DataRow row)
        {
            ElingOA6_Admin_DSJCJ.Model.DocReference model = new ElingOA6_Admin_DSJCJ.Model.DocReference();
            if (row != null)
            {
                if (row["FDocId"] != null && row["FDocId"].ToString() != "")
                {
                    model.FDocId = decimal.Parse(row["FDocId"].ToString());
                }
                if (row["FDocClsCd"] != null)
                {
                    model.FDocClsCd = row["FDocClsCd"].ToString();
                }
                if (row["FEntityNo"] != null)
                {
                    model.FEntityNo = row["FEntityNo"].ToString();
                }
                if (row.Table.Columns.Contains("FDocClsName"))
                {
                    if (row["FDocClsName"] != null)
                    {
                        model.FDocClsName = row["FDocClsName"].ToString();
                    }
                }
            }
            return model;
        }

    }
}
